

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@page isELIgnored="true" %>
<html>
<head>
    <title>采购订单入库</title>
    <%@include file="/comm/head.jsp"%>

</head>

<body>
<div id="root">

    <i-table ref="table"   :columns="columns" :data="pageResult.rows"  :height="600" border stripe @on-row-dblclick="rowClick" @on-selection-change="tableSelection=arguments[0]" >

        <template  slot-scope="{row}" slot="state">
            <span>{{row.state==0?"未审核":(row.state==1?"已审核":(row.state==2?"已确认":"已入库"))}}</span>

        </template>

    </i-table>

    <modal  v-model="xiang" height="500" :width="700"  >
        <div style="width: 660px;height: 200px ;border: 0.5px lightgray solid">
            <i-form :label-width="80" >
                <form-item label="流水号:"style=" margin-top: 5px;float: left;">
                    <i-input v-model="order.id" size="large" style="width: 110px;text-align: center"readonly/>
                </form-item>
                <form-item label="供应商:"style=" margin-top: 5px;float:left">
                    <i-input  style="width: 180px;text-align: center" v-model="order.providerIdName" size="large"readonly/>
                </form-item>

                <form-item label="状态:"style=" margin-top: 5px; float:left">
                    <i-select  v-model="order.state" style="width: 88px;background-color: #FFFFFF;" disabled="disabled">
                        <i-option value="0" >未审核</i-option>
                        <i-option value="1">已审核</i-option>
                        <i-option value="2" >已确认</i-option>
                        <i-option value="3">已入库</i-option>
                    </i-select>
                    <!--     <i-input  style="width: 110px;text-align: center" v-model="order.state" size="large"readonly/>-->
                </form-item>
                <form-item label="下单员:"style=" margin-top: 70px; margin-left:-630px;float: left">
                    <i-input   style="width: 88px;text-align: center"v-model="order.creatorName" size="large"readonly/>
                </form-item>
                <form-item label="审核员:"style="  margin-top: 70px; margin-left:-458px;float: left">
                    <i-input   style="width: 88px;text-align: center"v-model="order.checkerName" size="large"readonly/>
                </form-item>
                <form-item label="采购员:"style="  margin-top: 70px; margin-left:-302px;float: left">
                    <i-input   style="width: 88px;text-align: center"v-model="order.purchaserName" size="large"readonly/>
                </form-item>
                <form-item label="库管员:"style=" margin-top: 70px; margin-left:-145px;float: left">
                    <i-input  style="width: 88px;text-align: center" v-model="order.stockKeeperName" size="large"readonly/>
                </form-item>
                <form-item label="生成日期:" style="margin-top: 140px;margin-left:-650px;float: left">
                    <i-input  style="width: 88px;" v-model="order.createTime" size="large"readonly/>
                </form-item>
                <form-item label="审核日期:"style="margin-top: 140px;margin-left:-480px;float: left">
                    <i-input  style="width: 88px;text-align: center" v-model="order.checkTime" size="large"readonly/>
                </form-item>
                <form-item label="采购日期:"style="margin-top: 140px;margin-left:-320px;float: left">
                    <i-input  style="width: 88px;text-align: center" v-model="order.purchaseTime" size="large"readonly/>
                </form-item>
                <form-item label="出库日期:"style="margin-top: 140px;margin-left:-165px;float: left">
                    <i-input  style="width: 88px;text-align: center" v-model="order.stockTime" size="large"readonly/>
                </form-item>


            </i-form>
        </div>
        <i-table slot="footer" style="clear:both;" :columns="myColumnsGoods"  :data="mydata" :height="200" border stripe  @on-row-dblclick="rowClick1" >

            <template  slot-scope="{row}" slot="state">
                <span>{{row.state==0?"未入库":"已入库"}}</span>
            </template>
        </i-table>
    </modal>
    <modal v-model="OrderFlag" title="订单明细" width="500">

        <i-form :label-width="80" style=" height:135px"  >
            <form-item label="商品ID:"style="float: left;">
                <i-input v-model="orderDetail.goodsId" size="large" style="width: 110px;text-align: center"readonly/>
            </form-item>
            <form-item label="商品名称:" style="float: left;">
                <i-input  style="width: 120px;" v-model="orderDetail.goodsName" size="large"readonly/>
            </form-item>
            <form-item label="数量:"style="float: left">
                <i-input  style="width: 110px;text-align: center" v-model="orderDetail.num" size="large"readonly/>
            </form-item>
            <form-item label="仓库:" style="float: left;">
                <i-select v-model="orderDetail.storehouseId" style="width: 120px;">
                    <i-Option v-for="item1 in cangkuList" :value="item1.id" :key="item1.id">{{item1.cangkuName}}</i-Option>
                </i-select>
            </form-item>
            <hr style="clear: both;">
            <div >
                <i-button type="warning" icon="ios-log-in" @click="ruKu">入库</i-button>

                <i-button type="info" icon="md-archive" @click="caiDao">导出</i-button>
                <i-button type="error" icon="ios-print-outline" @click="exportPdf">打印浏览</i-button>
            </div>
        </i-form>
        <div slot="footer"></div>
    </modal>
    <modal  v-model="boH" >
        <div slot="footer">
            <i-form :label-width="80" >
                <form-item label="请输入驳回原因：">

                    <i-input  v-model="order.wayBillCode" type="textarea"></i-input>

                    <i-button type="primary" @click="boQue"  @on-selection-change="tableSelection=arguments[0]">确定</i-button>
                    <%-- <i-button type="primary" @click="boQu">取消</i-button>--%>


                </form-item>

            </i-form>
        </div>
    </modal>
    <Page :total="pageResult.total"
          :page-size="pageSize"
    <%--@on-change="pageNo=arguments[0];search();"--%>
          :current.sync="pageNo"

          show-sizer
          :page-size-opts="[5,10,15]"
          @on-change="search"
    <%--	@on-page-size-change切换每页条数时的回调，返回切换后的每页条数--%>
          @on-page-size-change="pageSize=arguments[0];search();"
    />
</div>
<script>

    new Vue({
        el:"#root",
        data: {
            columns: [
                {key:"id",title:"编号",align:"center"},
                {title: "生成日期", key: "createTime",width:"119",align:"center"},
                {title: "审核日期", key: "checkTime",width:"119",align:"center"},
                {title: "开始日期", key: "purchaseTime",width:"119",align:"center"},
                {title: "结束日期", key: "stockTime",width:"119",align:"center"},
                {title: "下单员", key: "creatorName",align:"center"},
                {title: "审核员", key: "checkerName",align:"center"},
                {title: "采购员", key: "purchaserName",align:"center"},
                {title: "库管员", key: "stockKeeperName",align:"center"},
                {title: "供应商", key: "providerIdName",align:"center",width:"110"},
                {title: "合计金额", key: "totalMoney",align:"center"},
                {title: "订单状态", slot:"state",align:"center"},
                {title: "通过状态", slot:"stat",align:"center"}
            ],

            myColumnsGoods:[

                {title: "商品编号", key: "goodsId"},
                {title: "商品名称", key: "goodsName"},
                {title: "价格", key: "price"},
                {title: "数量", key: "num"},
                {title: "金额", key: "money"},
                {title: "状态", slot: "state"},
            ],

            pageResult:{
                rows:[],
                total:50
            },
            tableSelection:[],
            pageNo:1,
            pageSize:5,
            xiang:false,
            mydata:[],
            order:{},
            oList:[],

            OrderFlag:false,
            orderDetail:{},
            cangkuList:[],
            cgOrderVo:{
                type:1,
                state:2,
                state1:2,

            },

        },
        mounted(){
            this.search();
            this.searchCangKuList();
        }, methods:{
            search(){
                axios.get(`${ctx}/caigou/cgddcx/search2/${this.pageNo}/${this.pageSize}`,{params:this.cgOrderVo})
                    .then(({data})=>{
                        this.pageResult=data.result;
                    });
            },


            //点击弹出订单详情
            rowClick(data1,index){//data 该行数据 ，index该行索引
                axios.get(`${ctx}/caigou/cgddcx/list?id=${data1.id}`)
                    .then(({data})=>{
                        this.mydata=data.result;
                        Object.assign(this.order,data1);
                        this.xiang=true
                    })
            },
            searchCangKuList(){
                axios.get(`${ctx}/jibenxinxi/ck/list1`)
                    .then(({data})=>{
                        this.cangkuList=data.result;
                    });
            },
            //点击弹出订单明细
            rowClick1(data2,index){//data 该行数据 ，index该行索引
                Object.assign(this.orderDetail,data2);
                this.OrderFlag=true;
            },
            ruKu(row){
                axios.post(`${ctx}/caigou/cgddcx/ruku`,this.orderDetail)
                    .then(({data})=>{
                        this.OrderFlag=false;
                        this.xiang=false;
                        iview.Message.success({content:data.msg});
                        this.search();
                    });
            },


            caiDao(){


                //获得你要携带的参数
                location.href=`${ctx}/caigou/cgddcx/exportExcelRu?id=${this.order.id}
                &providerIdName=${this.order.providerIdName}
                &creatorName=${this.order.creatorName}
                &checkerName=${this.order.checkerName}
                &purchaserName=${this.order.purchaserName}

                `;


            },
            exportPdf(){
                location.href=`${ctx}/caigou/cgddcx/exportPdfRu?id=${this.order.id}
                &providerIdName=${this.order.providerIdName}
                &creatorName=${this.order.creatorName}
                &checkerName=${this.order.checkerName}
                &purchaserName=${this.order.purchaserName}

                `;

            }
        }
    })
</script>
</body>
</html>
